package top.starmc.starquesthelper.listener

import ink.ptms.chemdah.api.event.collect.ObjectiveEvents
import ink.ptms.chemdah.api.event.collect.PlayerEvents
import ink.ptms.chemdah.api.event.collect.QuestEvents
import taboolib.common.platform.event.SubscribeEvent
import taboolib.common.platform.function.submitAsync
import top.starmc.starquesthelper.util.syncQuest

object QuestListener {
    @SubscribeEvent
    fun onAccept(event: QuestEvents.Accept.Post) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }

    @SubscribeEvent
    fun onRestart(event: QuestEvents.Restart.Post) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }

    @SubscribeEvent
    fun onComplete(event: QuestEvents.Complete.Post) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }

    @SubscribeEvent
    fun onFail(event: QuestEvents.Fail.Post) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }

    @SubscribeEvent
    fun onContinue(event: ObjectiveEvents.Continue.Post) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }

    @SubscribeEvent
    fun onSelect(event: PlayerEvents.Selected) {
        submitAsync {
            event.playerProfile.player.syncQuest()
        }
    }
}